/**
 * Created by PhpStorm.
 * User:  iyahe@qq.com (天明)
 * Date: 2019/8/2 0002
 * Time: 下午 14:53
 * Description:
 */
exports.default =  {
	set:function ($key,$value) {
		localStorage.setItem($key, this.value($value))
	},
	get:function ($key) {
		let value = localStorage.getItem($key);
		try{
			return JSON.parse(value);
		}catch (e) {
			return value;
		}
	},
	value:function ($value) {
		if (typeof $value === 'object') {
			return JSON.stringify($value)
		}
		return $value;
	},
	push:function ($key,$value) {
		let list = this.get($key);
		if(!list) list = [];
		if (list.indexOf($value) < 0) {
			list.push($value)
		}
		this.set($key, list);
		return list;
	}
}
